package com.ruoyi.net.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.net.mapper.NetElementPortMapper;
import com.ruoyi.net.domain.NetElementPort;
import com.ruoyi.net.service.INetElementPortService;

/**
 * 网元端口Service业务层处理
 * 
 * @author net
 * @date 2024-10-31
 */
@Service
public class NetElementPortServiceImpl implements INetElementPortService 
{
    @Autowired
    private NetElementPortMapper netElementPortMapper;

    /**
     * 查询网元端口
     * 
     * @param id 网元端口主键
     * @return 网元端口
     */
    @Override
    public NetElementPort selectNetElementPortById(String id)
    {
        return netElementPortMapper.selectNetElementPortById(id);
    }

    /**
     * 查询网元端口列表
     * 
     * @param netElementPort 网元端口
     * @return 网元端口
     */
    @Override
    public List<NetElementPort> selectNetElementPortList(NetElementPort netElementPort)
    {
        return netElementPortMapper.selectNetElementPortList(netElementPort);
    }

    /**
     * 新增网元端口
     * 
     * @param netElementPort 网元端口
     * @return 结果
     */
    @Override
    public int insertNetElementPort(NetElementPort netElementPort)
    {
        String uuid = IdUtils.simpleUUID();
        if (StringUtils.isEmpty(netElementPort.getId())) {
            netElementPort.setId(uuid);
        }
        netElementPort.setCreateBy(SecurityUtils.getUsername());
        netElementPort.setCreateTime(DateUtils.getNowDate());
        return netElementPortMapper.insertNetElementPort(netElementPort);
    }

    /**
     * 修改网元端口
     * 
     * @param netElementPort 网元端口
     * @return 结果
     */
    @Override
    public int updateNetElementPort(NetElementPort netElementPort)
    {
        netElementPort.setUpdateBy(SecurityUtils.getUsername());
        netElementPort.setUpdateTime(DateUtils.getNowDate());
        return netElementPortMapper.updateNetElementPort(netElementPort);
    }

    /**
     * 批量删除网元端口
     * 
     * @param ids 需要删除的网元端口主键
     * @return 结果
     */
    @Override
    public int deleteNetElementPortByIds(String[] ids)
    {
        return netElementPortMapper.deleteNetElementPortByIds(ids);
    }

    @Override
    public boolean checkNetElementPortBindStatus(String[] ids) {
        List<NetElementPort> list = netElementPortMapper.selectBindedByIds(ids);
        return list.isEmpty();
    }

    @Override
    public boolean checkPortBindStatusByElementId(String[] elementIds) {
        List<NetElementPort> list = netElementPortMapper.selectBindedByElementIds(elementIds);
        return list.isEmpty();
    }

    /**
     * 删除网元端口信息
     * 
     * @param id 网元端口主键
     * @return 结果
     */
    @Override
    public int deleteNetElementPortById(String id)
    {
        return netElementPortMapper.deleteNetElementPortById(id);
    }
}
